package repository

import (
	"gorm.io/gorm"
	"user/domain/model"
	"user/initialize"
)

type IUserRepository interface {
	GetOneById(id int) (*model.User, error)
}

func NewUserRepository() IUserRepository {
	return &UserRepository{
		db: initialize.TestDb,
	}
}

type UserRepository struct {
	db *gorm.DB
}

func (u *UserRepository) GetOneById(id int) (user *model.User, err error) {
	err = u.db.Where("id = ?", id).First(user).Error
	return
}
